package com.heima.wemedia.feign;

import com.heima.apis.wemedia.IWemediaFeign;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.pojos.WmUser;
import com.heima.wemedia.service.WmUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author zhangyan
 * @date 2021/4/25 17:34
 *
 * 其实是Controller,为了方便 直接实现了Feign接口
 */

@RestController
@RequestMapping("/api/v1/user")
public class WemediaFeign implements IWemediaFeign {

    @Autowired
    private WmUserService wmUserService;

    @Override
    @GetMapping("/findByName/{name}")
    public WmUser findByName(@PathVariable("name")String name) {
        return wmUserService.findByName(name);
    }

    @Override
    @PostMapping("/save")
    public ResponseResult save(@RequestBody WmUser wmUser) {
        return wmUserService.insert(wmUser);
    }
}
